package com.softeem.swaggerdemo.config;

import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.web.filter.HiddenHttpMethodFilter;

/**
 * 由于前端表单的提交方式只能选择post和get,
 * 因此对于restful请求风格来说：put和delete等无法直接通过配置method="put"或者method="delete"
 * 方法实现;
 * 要解决以上问题，在SpringBoot中只需要配置一个Bean即可:HiddenHttpMethodFilter
 * @Author mrchai 2020/10/12 15:18
 */
@Configuration
public class HttpRequestConfig {

    @Bean
    public HiddenHttpMethodFilter hiddenHttpMethodFilter(){
        HiddenHttpMethodFilter filter = new HiddenHttpMethodFilter();
        filter.setMethodParam("_method");
        return filter;
    }

    /*
        <bean id="hiddenHttpMethodFilter" class="org.springframework.web.filter.HiddenHttpMethodFilter">
            <property name="methodParam" value="_method"/>
        </bean>
     */

}
